package com.lin.cms.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.lin.cms.domain.SiteFlow;

public class SiteFlowValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return SiteFlow.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "flowId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "accessIp", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "accessPage", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "sessionId", "required");
	}

}
